package com.moli.iov.down.command.design.strategy.commandreqdto.impl;

import com.moli.iov.down.enums.command.CommandEnum;
import com.moli.iov.down.enums.OperateTypeEnum;
import com.moli.iov.down.enums.command.RemoteControlEnum;
import com.moli.iov.down.enums.command.extend.ExtendDoorLockEnum;
import com.moli.iov.down.model.dto.remoting.CommandDto;
import com.moli.iov.down.model.dto.remoting.CommandReqDto;
import com.moli.iov.down.command.design.strategy.commandreqdto.CommandReqDtoStrategy;

/**
 * <p>
 *  开门、关门
 * </p>
 *
 * @author: zql
 * @Date: 2018/12/28 11:49
 */
public class OpenCloseDoorStrategy implements CommandReqDtoStrategy {

    @Override
    public CommandDto make(CommandReqDto commandReqDto) {
        CommandDto commandDto = new CommandDto();
        commandDto.setVin(commandReqDto.getVin());
        commandDto.setIsRetry(commandReqDto.getIsRetry());

        commandDto.setCommand(CommandEnum.REMOTE_CONTROL.getFlag());
        commandDto.setControlCommand(RemoteControlEnum.DOOR_LOCK_CONTROL.getFlag());
        commandDto.setControlContent(commandReqDto.getOperateType() == OperateTypeEnum.OPEN_DOOR.getFlag() ?
                ExtendDoorLockEnum.OPEN.getFlag() : ExtendDoorLockEnum.CLOSE.getFlag());
        return commandDto;
    }
}
